import logging
import os
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from src.settings import MEDIA_ROOT

__author__ = 'Aleksej V.'

@login_required
def viewer(request):
    log = logging.getLogger(__name__)

#    lastlocation = request.GET.get("last", 0)
#    log.info("Log viewer, last location is: %d" % lastlocation)

    logfile = os.path.join(MEDIA_ROOT, "logs", "ittc.log")
    f = open(logfile, "rU")
    s = f.read()
    f.close()

    return HttpResponse(s, mimetype="text/plain")
